import component from "../../../common/component";
import CancelbookBtn from "@/components/CancelbookBtn"
import {Tag} from "antd";

class bookedrecord extends component {
    getColumns(): null {
        return [
            {
                title: '实验名称',
                dataIndex: 'tiliteName',
                key: 'tiliteName',
                width: 150,  
            },
            {
                title: '实验地点',
                dataIndex: 'location',
                key: 'location',
                width: 150,  
            },
            {
                title: '发布时间',
                dataIndex: 'releaseTime',
                key: 'releaseTime',
                width: 150,  
                sorter: (a, b) => {
                    // 将日期转成毫秒
                      const t1 = new Date(a.releaseTime).getTime();
                      const t2 = new Date(b.releaseTime).getTime();
                      return t1- t2
                    },
                    sortDirections: ['descend', 'ascend'],
                    defaultSortOrder: 'descend'
            },
            {
                title: '实验开始时间',
                dataIndex: 'stime',
                key: 'stime',
                width: 150,  
            },
            {
                title: '实验结束时间',
                dataIndex: 'etime',
                key: 'etime',
                width: 150,  
            },
            {
                title: '状态',
                dataIndex: 'state',
                key: 'state',
                width: 150,  
                render (state) { 
                    let config = {                      
                        '0': <Tag color="success">审批中</Tag>,
                        '1': <Tag color='default'>已拒绝</Tag>,
                        '2': <Tag color="processing">已通过</Tag>,
                    }
                    return config[state];
                }
            },
            {
                title: '操作',
                dataIndex: 'operation',
                fixed: 'right',
                width: 150,  
                render: (_, record) => {
                    return <CancelbookBtn record={record} cancebook={this.cancebook}/>
                }
            }
        ];
    }
}

export default bookedrecord;
